package com.example.businesscalcproject;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Juros_Simples_Composto extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// TODO Put your code here
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.juros_simples_composto);
		Log.d("Call","Entro");
		
		EditText taxa = (EditText) findViewById(R.id.txttaxa);
		String i = taxa.getText().toString();
		Log.d("Call","Entrouu "+i);
		
		Button call = (Button) findViewById(R.id.cal);
		call.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				EditText taxa = (EditText) findViewById(R.id.txttaxa);
				double tax = Double.parseDouble(taxa.getText().toString())/100;
				
				EditText tempo = (EditText) findViewById(R.id.txtempo);
				double temp = Double.parseDouble(tempo.getText().toString());
				
				EditText capital = (EditText) findViewById(R.id.txcapital);
				double cap = Double.parseDouble(capital.getText().toString());
				
				double jstax = 0;
				double jsmont = 0;
				
				jstax= cap*tax*temp;
				jsmont = jstax+cap;
				
				TextView Tvtax = (TextView) findViewById(R.id.rsimples);
				Tvtax.setText(""+jstax);
				TextView Tvmont = (TextView) findViewById(R.id.rmont);
				Tvmont.setText(""+jsmont);
				
				double jcmont = cap*Math.pow((1+tax), temp);
				double jctax = jcmont-cap;
				
				TextView tvcomp = (TextView) findViewById(R.id.rcomposto);
				tvcomp.setText(""+jctax);
				TextView tvcomptax = (TextView) findViewById(R.id.rcomp);
				tvcomptax.setText(""+jcmont);
				
			}
		});
	}

}
